home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PHRO.ZIP / MSE_TP.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-26  |  11KB  |  230 lines

  1.  {──────────────────────────────────────────────────────────────────────────}
  2.  {                    Bells, Whistles, and Sound Boards                     }
  3.  {       Copyright (c) 1993-95, Edward Schlunder. All Rights Reserved.      }
  4.  {══════════════════════════════════════════════════════════════════════════}
  5.  { MSE_TP.PAS - Turbo Pascal <-> MSE Interface Unit file.                   }
  6.  {              Requires TPX_MSE.OBJ to compile.                            }
  7.  {              Written by Alex Chalfin (1994-95)                           }
  8.  {                                                                          }
  9.  {──────────────────────────────────────────────────────────────────────────}
  10.  
  11. Unit MSE_TP;
  12. {$G+}  { Enable 286 Instructions }
  13.  
  14. Interface
  15.  
  16. Type
  17.  
  18.   GDMHeader = Record
  19.     IDString     : Longint;              { 'GDM■' = $FE4D4447        }
  20.     SongTitle    : Array[0..31] of Char; { Title of the Song         }
  21.     SongMusician : Array[0..31] of Char; { generally not used        }
  22.     EOF          : Array[0..2] of Char;  { DOS EOF marker, 13,10,26  }
  23.     IDString2    : Longint;              { 'GMFS' = $53464D47        }
  24.     FormatMajor  : Byte;                 { Format major version num  }
  25.     FormatMinor  : Byte;                 { Format minor version num  }
  26.     TrackerID    : Word;                 { Tracker's ID              }
  27.     TrackerMajor : Byte;                 { Tracker's major ver num   }
  28.     TrackerMinor : Byte;                 { Tracker's minor ver num   }
  29.     PanMap       : Array[0..31] of Byte; { Default panning locations }
  30.     InitVol      : Byte;                 { Default music volume      }
  31.     InitTempo    : Byte;                 { Default music tempo       }
  32.     InitBPM      : Byte;                 { Default music BPM         }
  33.     FormOrigin   : Word;                 { Format origin             }
  34.     OrderOffset  : Longint;
  35.     NumOrders    : Byte;
  36.     PatternOffset: Longint;
  37.     NumPatterns  : Byte;
  38.     OffsetSamHead: Longint;
  39.     OffsetSamData: Longint;
  40.     NumSamples   : Byte;
  41.     OffsetMessage: Longint;
  42.     MessageLen   : Longint;
  43.     OffsetScrolly: Longint;
  44.     ScrollyLen   : Word;
  45.     OffsetGraph  : Longint;
  46.     GraphLen     : Word;
  47.   End;
  48.  
  49.   SamHeader = Record
  50.     SamName      : Array[0..31] of Byte;   { Instrument name         }
  51.     FileName     : Array[0..11] of Byte;   { Sample Filename         }
  52.     EmsHandle    : Byte;                   { Ems Handle used         }
  53.     Length       : Longint;                { Length of sample        }
  54.     LoopBegin    : Longint;                { Offset of Loop Start    }
  55.     LoopEnd      : Longint;                { Offset of Loop End      }
  56.     Flags        : Byte;                   { Sample Flags            }
  57.     C4Hertz      : Word;                   { Middle C Playback Hertz }
  58.     Volume       : Byte;                   { Sample's Default Volume }
  59.     Pan          : Byte;                   { this is not really used }
  60.     Segment      : Word;                   { Segment of sample mem   }
  61.   End;
  62.  
  63.   ChannelType = Record
  64.     MixFlags       : Byte;             { Mixing Flags                }
  65.     MixLBeg        : Word;             { Offset of loop beginning    }
  66.     MixLEnd        : Word;             { Offset of loop ending       }
  67.     MixFinetune    : Word;             { Finetune (C-4 Hertz)        }
  68.     MixRate        : Longint;          { Sample rate/period of sound }
  69.     MixSeg         : Word;             { Segment of sound            }
  70.     MixOff         : Word;             { Offset of next byte to mix  }
  71.     MixVolume      : Byte;             { Volume of channel           }
  72.     MixInc         : Word;             { Incrementation for each sample. MSB.LSB }
  73.     MixIncRemain   : Byte;             { Remainder from last increment }
  74.     MusSample      : Byte;             { Currently played sample number }
  75.     MusNote        : Byte;             { Currently played note       }
  76.     MusOctave      : Byte;             { Currently played octave     }
  77.     MusEffect1     : Byte;             { Music Effect Number (1)**   }
  78.     MusEffDat1     : Word;             { Music Effect Data   (1)**   }
  79.     MusEffect2     : Byte;             { Music Effect Number (2)*    }
  80.     MusEffDat2     : Word;             { Music Effect Data   (2)*    }
  81.     MusEffect3     : Byte;             { Music Effect Number (3)     }
  82.     MusEffDat3     : Word;             { Music Effect Data   (3)     }
  83.     MusEffect4     : Byte;             { Music Effect Number (4)     }
  84.     MusEffDat4     : Word;             { Music Effect Data   (4)     }
  85.     VUMeter        : Byte;             { Volume Meter value          }
  86.     MusVolRate     : Word;             { Old Vol Slide Speed         }
  87.     MusPortaRate   : Word;             { Old Porta to Note Speed     }
  88.     MusVibWave     : Byte;             { Vibrato Waveform Select     }
  89.     MusVibPosition : Byte;             { Vibrato Table Position      }
  90.     MusVibSpeed    : Byte;             { Vibrato Speed (x0h)         }
  91.     MusVibDepth    : Byte;             { Vibrato Depth (0yh)         }
  92.     MusTrmWave     : Byte;             { Tremolo Waveform Select     }
  93.     MusTrmPosition : Byte;             { Tremolo Table Position      }
  94.     MusTrmSpeed    : Byte;             { Tremolo Speed               }
  95.     MusTrmDepth    : Byte;             { Tremolo Depth               }
  96.     MusRetrigSpeed : Byte;             { Retrigger speed             }
  97.     MusRetrigSlide : Byte;             { Retrigger volume slide      }
  98.     MusGlissFunk   : Byte;             { Funk It (Invert Loop) Speed }
  99.     MusFunkOffset  : Byte;             { Funk It position            }
  100.     MusWaveStart   : Word;             { Funk It funk pointer (offset into sample) }
  101.     MixPanning     : Byte;             { Pan position                }
  102.     MixHandle      : Byte;             { EMS Handle this sample resides on }
  103.     MixMonoVol     : Byte;             { Mono volume value           }
  104.     MixLftVol      : Byte;             { Left speaker mixing volume  }
  105.     MixRgtVol      : Byte;             { Right speaker mixing volume }
  106.     GUSAddress     : Longint;          { Address of start position in GUS memory }
  107.     MusArpeggio    : Byte;             { Old Arpeggio speed          }
  108.     MusPortaUD     : Byte;             { Old Porta Up/Down speed     }
  109.     Reserved       : Array[0..63] of Char;    { For future expansion }
  110.   End;                                                               
  111.  
  112. Function LoadMSE(Var FileName : String; FileOfs : Longint; Ovr,
  113.                  BufferSize : Word; Var BaseIO : Word; Var IRQ, DMA : Byte) : Word;
  114. Function DeviceName : String;
  115. Function StartOutput(Channels, Amp : ShortInt) : Word;
  116. Function MixStatus : Word;
  117. Function MusicStatus : Word;
  118. Function MusicBPM(BPM : Byte) : Byte;
  119. Function MusicTempo(Tempo : Byte) : Byte;
  120. Function MusicOrder(Order : Byte) : Byte;
  121. Function MusicPattern(Pat : Byte) : Byte;
  122. Function MusicRow : Byte;
  123. Function MusicLoop(LoopStatus : Byte) : Byte;
  124. Function MusicVolume(Vol : Byte) : Byte;
  125. Function ChannelPan(Chan, Pan : Byte) : Byte;
  126. Function ChannelVU(Chan, Vu : Byte) : Byte;
  127. Function ChannelVol(Channel, NewVol : Byte) : Word;
  128. Function ChannelPos(Channel, NewPos : Word) : Word;
  129. Function LoadGDM(Var Handle : File; FileOfs : Longint; Var Flags : Word; Var GHead) : Word;
  130. Function EmsExist : Boolean;
  131. Procedure GetChannelTable(Chan : Byte; TSeg, TOff : Word);
  132. Procedure FreeMSE;
  133. Procedure StopOutput;
  134. Procedure MixForground;
  135. Procedure SetAutoMix(Mix : Byte);
  136. Procedure StartMusic;
  137. Procedure StopMusic;
  138. Procedure GetSampleTable(Samp : Byte; TSeg, TOff : Word);
  139. Procedure GetMainScope(Var Left, Right : Word);
  140. Procedure UnloadModule;
  141. Procedure PlaySample(Channel, Sample : Byte; Rate : Word; Volume, Pan : Byte);
  142. Procedure PlayNote(Channel, Sample, Octave, Note : Byte);
  143. Procedure AmigaHertz(Hertz : Longint);
  144.  
  145. Function AllocSample(SamNum : Byte; Var SamHead) : Word;
  146. Function FreeSample(SamNum : Byte) : Word;
  147.  
  148. Implementation
  149.  
  150. Const
  151.   EmmIdCode : Array[0..7] of Char = ('E','M','M','X','X','X','X','0');
  152.  
  153. {$F+}
  154. {$L TPX_MSE.OBJ}
  155. Function LoadMSE(Var FileName : String; FileOfs : Longint; Ovr,
  156.                  BufferSize : Word; Var BaseIO : Word; Var IRQ, DMA : Byte) : Word; External;
  157. Procedure FreeMSE; External;
  158. Function DeviceName : String; External;
  159.  
  160. Function StartOutput(Channels, Amp : ShortInt) : Word; External;
  161. Procedure StopOutput; External;
  162.  
  163. Function MixStatus : Word; External;
  164. Procedure MixForground; External;
  165. Procedure SetAutoMix(Mix : Byte); External;
  166.  
  167. Procedure StartMusic; External;
  168. Procedure StopMusic; External;
  169. Function MusicStatus : Word; External;
  170.  
  171. Function MusicBPM(BPM : Byte) : Byte; External;
  172. Function MusicTempo(Tempo : Byte) : Byte; External;
  173. Function MusicOrder(Order : Byte) : Byte; External;
  174. Function MusicPattern(Pat : Byte) : Byte; External;
  175. Function MusicRow : Byte; External;
  176. Function MusicLoop(LoopStatus : Byte) : Byte; External;
  177. Function MusicVolume(Vol : Byte) : Byte; External;
  178.  
  179. Function ChannelPan(Chan, Pan : Byte) : Byte; External;
  180. Function ChannelVU(Chan, Vu : Byte) : Byte; External;
  181. Function ChannelVol(Channel, NewVol : Byte) : Word; External;
  182. Function ChannelPos(Channel, NewPos : Word) : Word; External;
  183.  
  184. Function LoadGDM(Var Handle : File; FileOfs : Longint; Var Flags : Word; Var GHead) : Word; External;
  185. Procedure UnloadModule; External;
  186.  
  187. Procedure GetChannelTable(Chan : Byte; TSeg, TOff : Word); External;
  188. Procedure GetSampleTable(Samp : Byte; TSeg, TOff : Word); External;
  189. Procedure GetMainScope(Var Left, Right : Word); External;
  190.  
  191. Procedure AmigaHertz(Hertz : Longint); External;
  192. Procedure PlaySample(Channel, Sample : Byte; Rate : Word; Volume, Pan : Byte); External;
  193. Procedure PlayNote(Channel, Sample, Octave, Note : Byte); External;
  194.  
  195. Function AllocSample(SamNum : Byte; Var SamHead) : Word; External;
  196. Function FreeSample(SamNum : Byte) : Word; External;
  197.  
  198. {$F-}
  199.  
  200. Function EmsExist : Boolean; Assembler;
  201. { Checks to see if EMS memory exists }
  202. { Returns TRUE/FALSE                 }
  203.  
  204. Asm
  205.   Xor     ax, ax
  206.   Mov     es, ax
  207.   Mov     bx, 19Eh
  208.   Mov     ax, es:[bx]
  209.   Mov     es, ax
  210.   Mov     cl, 8
  211.   Mov     si, 10
  212.   Xor     bx, bx
  213.  @CmpLoop:
  214.   Mov     al, es:[si]
  215.   Cmp     al, Byte Ptr ds:[EmmIdCode+bx]
  216.   Jne     @EmsNoExist
  217.   Inc     si
  218.   Inc     bx
  219.   Dec     cl
  220.   Jnz     @CmpLoop
  221.  @EmsYesExist:
  222.   Mov     ax, 0FFFFh
  223.   Ret
  224.  @EmsNoExist:
  225.   Xor     ax, ax
  226. End;
  227.  
  228. End.
  229.  
  230.